package org.swidgets.base.spanels;

import org.swidgets.base.BorderStyleRepository;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class SFormPanel extends Composite {
	protected final SFrame frame=new SFrame();
	private SimplePanel simplePanel = new SimplePanel();
	
	private static final boolean isDesignTime() {
		return false;
	}
	
	
	public SFormPanel(String caption,String width,String height){
		super();
		this.initWidget(simplePanel);		
		initFormPanel();
		simplePanel.setHeight(height);
		simplePanel.setWidth(width);	
		frame.setCaption(caption);	
		frame.addStyleName("fontZero");
		frame.setWidth("100%");
		frame.setHeight("100%");
	}
			
	public SFormPanel (){
		this("FormPanel","100px","100px");
		//frame.setWidth("100%");
	}
	
	public SFormPanel(String caption){
		this(caption,"100px","100px");
	}
	
	public void initFormPanel(){		
		simplePanel.add(frame);	
		frame.setStyle(BorderStyleRepository.framePanel);
		frame.setHeight("100%");
	}
	
	public void add(Widget w){
		frame.setBodyWidget(w);
	}
	
	public void addMessage(Widget w) {
		frame.addMessage(w);
	}
	public void onBrowserEvent(Event event) {
		simplePanel.onBrowserEvent(event);
	}
	public void setCaption(String title) {
		frame.setCaption(title);
	}

	public void setWidth(String width){
		simplePanel.setWidth(width);		
	}

	public void setHeight(String height){
		simplePanel.setHeight(height);		
	}
}
